//
//  File.swift
//
//
//  Created by didi on 2022/9/14.
//

import Molecular
import MolecularRedirectObjects
import Vapor

struct RedirectRouter: MolecularRouter {
    let ruleAdminController = RedirectRuleAdminController()
    let ruleApiController = RedirectRuleApiController()

    func adminRoutesHook(args: HookArguments) {
        ruleAdminController.setUpRoutes(args.routes)
        args.routes.get(Redirect.pathKey.pathComponent) { request -> Response in
            request.templates.renderHtml(SystemAdminModulePageTemplate(.init(title: "Redirect", tag: RedirectAdminWidgetTemplate().render(request))))
        }
    }

    func apiRoutrsHook(args: HookArguments) {
        ruleApiController.setUpRoutes(args.routes)
    }
}
